<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title >小强博客</title>
    <link  rel="stylesheet" type="text/css" href="/Public/css/bootstrap.min.css" />
    <script type="text/javascript" src="/Public/js/jquery-3.1.1.js"></script>
    <script type="text/javascript" src="/Public/js/bootstrap.js"></script>
    <script type="text/javascript" src="/Public/js/layer.js"></script>
</head>
<style>
    .navbar-inverse{
   border-radius: inherit;
    }
    .navbar nav li:hover{
        background-color: white;
    }
</style>
<body>
<nav class="navbar navbar-inverse">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header ">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Blog v1.0</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="<?php if( CONTROLLER_NAME == 'Index' ): ?>active<?php endif; ?>"><a href="<?php echo U('Index/index');?>">
                <i class="glyphicon glyphicon-home">&nbsp;</i>首页  <span class="sr-only">(current)</span></a></li>
                <li  class="<?php if( CONTROLLER_NAME == 'Content' ): ?>active<?php endif; ?>"><a href="<?php echo U('Content/index');?>">内容</a></li>
                <li class="<?php if( CONTROLLER_NAME == 'Tools' ): ?>active<?php endif; ?>"><a href="<?php echo U('Tools/index');?>">功能</a></li>
                <li class="<?php if( CONTROLLER_NAME == '' ): ?>active<?php endif; ?>"><a href="#">用户</a></li>

            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/index.php"> 前台首页</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false"><span>您好 </span>&nbsp;<?php echo ($_SESSION['blog_admin']['name']); ?></a>
                    <ul class="dropdown-menu">
                        <li><a href="<?php echo U('Index/profile');?>">管理档案 </a></li>
                        <li><a href="<?php echo U('Index/quite');?>">注销 </a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<script type="text/javascript" src="/Public/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="/Public/uploadify/uploadify.css" >
<div class="container">
    <div class="row">

                <div class="btn-group-vertical col-md-2">
        <a  class="btn btn-default  <?php if( CONTROLLER_NAME == 'Category' ): ?>active<?php endif; ?>" href="<?php echo U('Category/index');?>">
        <i class="glyphicon glyphicon-leaf">&nbsp;</i>分类管理 </a>
        <a  class="btn btn-default  <?php if( CONTROLLER_NAME == 'Tag' ): ?>active<?php endif; ?>" href="<?php echo U('Tag/index');?>" >
        <i class="glyphicon glyphicon-tags">&nbsp;</i>标签管理</a>
        <a  class="btn btn-default  <?php if( CONTROLLER_NAME == 'Article' ): ?>active<?php endif; ?>" href="<?php echo U('Article/index');?>" >
        <i class="glyphicon glyphicon-list-alt">&nbsp;</i>文章管理</a>

    </div>

        <div class="col-md-10" >
            <form action="<?php echo U('Article/savehandler');?>" method="post">
                <input type="hidden" name="aid" value="<?php echo ($articles['aid']); ?>">
                <script type="text/javascript"   src="/Public/ueditor/ueditor.config.js"></script>
                <script type="text/javascript"    src="/Public/ueditor/ueditor.all.js"></script>
                <script type="text/javascript"    src="/Public/ueditor/lang/zh-cn/zh-cn.js"></script>
                <div class="row">

                    <div class="page-header"><h3><?php echo ($page_title); ?></h3></div>
                    <div class="col-md-8" style="padding: 0;">

                        <div class="btn-group  role="group" aria-label="" style="margin-bottom:10px;" >
                        <a  class="btn btn-default <?php if(CONTROLLER_NAME == 'Article' && ACTION_NAME == 'index'): ?>active<?php endif; ?>" href="<?php echo U('Article/index');?>">所有文章</a>&nbsp;
                        <a  class="btn btn-default <?php if(CONTROLLER_NAME == 'Article' && ACTION_NAME == 'add'): ?>active<?php endif; ?>" href="<?php echo U('Article/add');?>" style="margin-bottom:10px;"> 添加文章</a>
                    </div>

                    <div class="form-group">
                        <input type="text" class="form-control"  placeholder=" 题目" name="title" value="<?php echo ($articles['title']); ?>">
                    </div>
                    <div class="form-group">
                        <select class="form-control" name="category_cid">
                            <option value="0">选择类</option>
                            <?php if(is_array($category)): foreach($category as $key=>$c): ?><option value="<?php echo ($c['id']); ?>"  <?php if($articles['category_cid'] == $c['id']): ?>selected<?php endif; ?>>
                                    <?php if($c['pid'] != 0): echo str_repeat('&nbsp',$c['level']*8); endif; echo ($c['cname']); ?></option><?php endforeach; endif; ?>

                        </select>
                    </div>
                    <div class="form-group" >
                        <textarea class="form-control" name="description" rows="6"  placeholder=" 简介内容 "><?php echo ($articles['description']); ?></textarea>
                    </div>

                    <div class="form-group" >
                        <textarea name="content" id="editor"  style="height:400px;width: 100%;" placeholder="内容"><?php echo ($articles['content']); ?></textarea>
                        <script>
                            var ue = UE.getEditor('editor');
                        </script>
                    </div>

                    <div class="form-group">
                        <input type="text" class="form-control"  placeholder="排序" name="sort" value="<?php echo ($articles['sort']); ?>">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control"  placeholder="作者 " name="author" value="<?php echo ($articles['author']); ?>">
                    </div>
                    <div class="radio">
                        <label class="radio-inline">
                            <input type="radio" name="status"  value="1" <?php if($articles['status']==1): ?>checked<?php endif; ?>> 开启
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="status"  value="0" <?php if($articles['status']==0): ?>checked<?php endif; ?>> 关闭
                        </label>
                    </div>
                    <button type="submit" class="btn btn-primary">保存</button>

                </div>
                <div class="col-md-4">
                    <div class="panel panel-default">
                        <div class="panel-heading"> 封面</div>
                        <div class="panel-body">
                            <span value="time()" name="add_time"></span>
                            <input type="text" class="form-control" id="thumb" name="thumb" value="<?php echo ($articles['thumb']); ?>">
                            <input id="file" type="file" multiple="false">
                            <br>
                            <img src="/<?php echo ($articles['thumb']); ?>" alt="" id="thumber" >
                            <script type="text/javascript">
                                $(function() {
                                    $('#file').uploadify({
                                        'formData'     : {
                                            '<?php echo session_name();?>' : '<?php echo session_id();?>',
                                        },
                                        'fileTypeDesc' : '上传文件',//上传描述
                                        'fileTypeExts' : '*.jpg;*.png',
                                        'swf' : '/Public/uploadify/uploadify.swf',
                                        'uploader' : "<?php echo U('Article/uploadThumb');?>",
                                        'buttonText':'选择文件',
                                        'fileSizeLimit' : '2000KB',
                                        'uploadLimit' : 1,//上传文件数
                                        'width':65,
                                        'height':25,
                                        'successTimeout':10,//等待服务器响应时间
                                        'removeTimeout' : 0.2,//成功显示时间
                                        'onUploadSuccess' : function(file, data, response) {
                                            //转为json
                                            data=$.parseJSON(data);
                                            $('#thumb').val(data);
                                            $('#thumber').attr('src','/'+data);
                                            //获得图片地址
                                            //console.log(data);
                                            /*var imageUrl = data.url;
                                             var li="<li path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"'/><input type='hidden' name='thumb' value='"+data.path+"'/></li>";
                                             $("#uploadList ul").prepend(li);*/
                                        }
                                    });
                                });
                            </script>
                            <div id="uploadList">
                            <ul>

                            </ul>
                        </div>
                        </div>
                    </div>

                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">所有标签</h3>
                        </div>
                        <div class="panel-body">
                            <?php if(is_array($tags)): foreach($tags as $key=>$t): ?><label class="checkbox-inline">  <input type="checkbox"  value="<?php echo ($t['tid']); ?>" name="tag[]"
                                    <?php if(in_array($t['tid'],$article_tag)): ?>checked<?php endif; ?> > <?php echo ($t['tname']); ?> </label><?php endforeach; endif; ?>

                        </div>
                    </div>
                </div>
        </div>
        </form>
    </div>

</div>
</div>
</body>
</html>